home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1997 February / macformat-047.iso / Shareware Plus / Developers / The Gray Council 1.2.1 / projects / PowerPlant / MyApplication.cp < prev    next >
Encoding:
Text File  |  1996-11-06  |  22.7 KB  |  778 lines  |  [TEXT/CWIE]

  1. //
  2. // GrayCouncil
  3. // Copyright ©1996 by Trygve Isaacson. All Rights Reserved.
  4. //
  5. // This file contains the GrayCouncil PowerPlant test program's
  6. // application class implementation.
  7. //
  8.  
  9. #include "MyApplication.h"
  10.  
  11. #include <LGrowZone.h>
  12. #include <LWindow.h>
  13. #include <PP_Messages.h>
  14. #include <PP_Resources.h>
  15. #include <PPobClasses.h>
  16. #include <UDrawingState.h>
  17. #include <UMemoryMgr.h>
  18. #include <URegistrar.h>
  19. #include <LEditField.h>
  20. #include <LGroupBox.h>
  21. #include <LPicture.h>
  22. #include <UModalDialogs.h>
  23.  
  24. #include "MyConstants.h"
  25.  
  26. void main(void)
  27.     {
  28.     //
  29.     // Initialize PowerPlant.
  30.     //
  31.  
  32.     SetDebugThrow_(debugAction_Alert);
  33.     SetDebugSignal_(debugAction_Alert);
  34.  
  35.     InitializeHeap(3);
  36.  
  37.     UQDGlobals::InitializeToolbox(&qd);
  38.     
  39.     new LGrowZone(20000);
  40.  
  41.     //
  42.     // Initialize The Gray Council.
  43.     //
  44.  
  45.     (void) InitGrayCouncilPP();
  46.  
  47.     //
  48.     // Run our app.
  49.     //
  50.  
  51.     MyApplication    myApp;
  52.     myApp.Run();
  53.     }
  54.  
  55. #undef Inherited
  56. #define Inherited LApplication
  57.  
  58. MyApplication::MyApplication()
  59.     {
  60.     RegisterAllPPClasses();
  61.  
  62.     // Init the pointers & stuff used during idling.
  63.     mProgressIndicator1 = NULL;
  64.     mProgressIndicator2 = NULL;
  65.     mMovingProgressOrigin = false;
  66.     mSkipNext = false;
  67.     
  68.     this->StartIdling();    // make LPeriodical start idling
  69.     }
  70.  
  71. MyApplication::~MyApplication()
  72.     {
  73.     }
  74.  
  75. void MyApplication::StartUp()
  76.     {
  77.     //
  78.     // Create and open our main window.
  79.     //
  80.  
  81.     LWindow        *theWindow;
  82.     theWindow = LWindow::CreateWindow(kMainWindowViewID, this);    
  83.     theWindow->Show();
  84.     
  85.     //
  86.     // Set up to catch button clicks in our main window.
  87.     //
  88.  
  89.     for (UInt32 i = 0; i < kNumDialogs; i++)
  90.         {
  91.         LControl*    aButton = (LControl*) theWindow->FindPaneByID(kMyCommandBase + i);
  92.         if (aButton != NULL)    // not all of our commands have a button!
  93.             aButton->AddListener(this);
  94.         }
  95.     }
  96.  
  97. Boolean MyApplication::ObeyCommand(CommandT inCommand, void *ioParam)
  98.     {
  99.     Boolean    cmdHandled = true;
  100.     
  101.     if ((inCommand >= kMyCommandBase) && (inCommand < kMyCommandBase + kNumDialogs))
  102.         {
  103.         // Got a menu command for one of our dialogs. Run the
  104.         // corresponding dialog.
  105.  
  106.         this->PoseExampleDialog(inCommand - kMyCommandBase);
  107.         }
  108.     else if (inCommand == cmd_About)
  109.         {
  110.         // Run the about box.
  111.  
  112.         StDialogHandler    aDlgHandler(kAboutBoxViewID, this);
  113.         LWindow*        aDialog = aDlgHandler.GetDialog();
  114.         MessageT        hitMessage;
  115.         
  116.         aDialog->Show();
  117.         
  118.         do
  119.             {
  120.  
  121.             hitMessage = aDlgHandler.DoDialog();
  122.  
  123.             } while ((hitMessage != msg_OK) && (hitMessage != msg_Cancel));
  124.         }
  125.     else
  126.         cmdHandled = Inherited::ObeyCommand(inCommand, ioParam);
  127.     
  128.     return cmdHandled;
  129.     }
  130.  
  131. void MyApplication::FindCommandStatus(CommandT inCommand, Boolean& outEnabled, Boolean& outUsesMark, Char16& outMark, Str255 outName)
  132.     {
  133.     // Enable our menu commands.
  134.  
  135.     if ((inCommand >= kMyCommandBase) && (inCommand < kMyCommandBase + kNumDialogs))
  136.         outEnabled = true;
  137.     else
  138.         Inherited::FindCommandStatus(inCommand, outEnabled, outUsesMark, outMark, outName);
  139.     }
  140.  
  141. static SInt32 MaxSInt32(SInt32 a, SInt32 b) { return (a > b) ? a : b; }
  142.  
  143. void MyApplication::ListenToMessage(MessageT inMessage, void *ioParam)
  144.     {
  145.     if ((inMessage >= kMyCommandBase) && (inMessage < kMyCommandBase + kNumDialogs))
  146.         {
  147.         // Got a button click in our main window. Run the
  148.         // corresponding dialog.
  149.  
  150.         this->PoseExampleDialog(inMessage - kMyCommandBase);
  151.         }
  152.     else switch (inMessage)
  153.         {
  154.         case 'ENAB':
  155.             this->EnableDisableDialog(mCurrentDialogIndex, mCurrentDialog, *((SInt32*) ioParam) != 0);
  156.             break;
  157.         
  158.         case 'SBAR':
  159.             {
  160.             SInt32    newScrollValue = *((SInt32*) ioParam);
  161.             LPane*    valueTextPane = mCurrentDialog->FindPaneByID('SBTX');
  162.             
  163.             valueTextPane->SetValue(newScrollValue);
  164.             valueTextPane->Draw(NULL);
  165.             }
  166.             break;
  167.         
  168.         case 'LIVE':
  169.         case 'PROP':
  170.             {
  171.             AGAScrollBarPP*    aScrollBar;
  172.             LStdCheckBox*    liveCheckBox = (LStdCheckBox*) mCurrentDialog->FindPaneByID('LIVE');
  173.             LStdCheckBox*    propCheckBox = (LStdCheckBox*) mCurrentDialog->FindPaneByID('PROP');
  174.             Boolean            live = (liveCheckBox->GetValue() != 0);
  175.             Boolean            proportional = (propCheckBox->GetValue() != 0);
  176.  
  177.             ThrowIfNil_(aScrollBar = (AGAScrollBarPP*) mCurrentDialog->FindPaneByID('SBAR'));
  178.             aScrollBar->mAGAObject->SetAttributes(AGAObject::kHorizontal, live, proportional);
  179.             if (inMessage == 'PROP')
  180.                 aScrollBar->Refresh();
  181.  
  182.             ThrowIfNil_(aScrollBar = (AGAScrollBarPP*) mCurrentDialog->FindPaneByID(PaneIDT_HorizontalScrollBar));
  183.             aScrollBar->mAGAObject->SetAttributes(AGAObject::kHorizontal, live, proportional);
  184.             if (inMessage == 'PROP')
  185.                 aScrollBar->Refresh();
  186.  
  187.             ThrowIfNil_(aScrollBar = (AGAScrollBarPP*) mCurrentDialog->FindPaneByID(PaneIDT_VerticalScrollBar));
  188.             aScrollBar->mAGAObject->SetAttributes(AGAObject::kVertical, live, proportional);
  189.             if (inMessage == 'PROP')
  190.                 aScrollBar->Refresh();
  191.             }
  192.             break;
  193.  
  194.         case 'BIGP':
  195.         case 'LILP':
  196.             {
  197.             LStdRadioButton*    bigRadio = (LStdRadioButton*) mCurrentDialog->FindPaneByID('BIGP');
  198.             LPicture*            thePicture = (LPicture*) mCurrentDialog->FindPaneByID(620);
  199.             
  200.             thePicture->SetPictureID((bigRadio->GetValue() == 0) ? kLittlePictureID : kBigPictureID);
  201.             thePicture->Refresh();
  202.             }
  203.             break;
  204.     
  205.         case 'LRGT':
  206.         case 'SMLT':
  207.             {
  208.             LStdRadioButton*    largeRadio = (LStdRadioButton*) mCurrentDialog->FindPaneByID('LRGT');
  209.             AGATabPanelPP*        tabPanel;
  210.             Boolean                small = (largeRadio->GetValue() == 0);
  211.             
  212.             tabPanel = (AGATabPanelPP*) mCurrentDialog->FindPaneByID('TAB1');
  213.             tabPanel->mAGAObject->SetTabSize(small ? AGATabPanel::kSmallTabs : AGATabPanel::kLargeTabs);
  214.             tabPanel->mAGAObject->SetLabelsStyle(small ? gAGAStdBoldSmallStyle : gAGAStdSystemStyle);
  215.             tabPanel->Refresh();
  216.             
  217.             tabPanel = (AGATabPanelPP*) mCurrentDialog->FindPaneByID('TAB2');
  218.             tabPanel->mAGAObject->SetTabSize(small ? AGATabPanel::kSmallTabs : AGATabPanel::kLargeTabs);
  219.             tabPanel->mAGAObject->SetLabelsStyle(small ? gAGAStdBoldSmallStyle : gAGAStdSystemStyle);
  220.             tabPanel->Refresh();
  221.             }
  222.             break;
  223.     
  224.         case 'LVSL':
  225.         case 'PRSL':
  226.             {
  227.             AGASliderPP*    aSlider;
  228.             LStdCheckBox*    liveCheckBox = (LStdCheckBox*) mCurrentDialog->FindPaneByID('LVSL');
  229.             LStdCheckBox*    propCheckBox = (LStdCheckBox*) mCurrentDialog->FindPaneByID('PRSL');
  230.             Boolean            live = (liveCheckBox->GetValue() != 0);
  231.             Boolean            proportional = (propCheckBox->GetValue() != 0);
  232.  
  233.             aSlider = (AGASliderPP*) mCurrentDialog->FindPaneByID('VSPL');
  234.             aSlider->mAGAObject->SetAttributes(AGAObject::kVertical, live, proportional);
  235.             if (inMessage == 'PRSL') aSlider->Refresh();
  236.  
  237.             aSlider = (AGASliderPP*) mCurrentDialog->FindPaneByID('VSPR');
  238.             aSlider->mAGAObject->SetAttributes(AGAObject::kVertical, live, proportional);
  239.             if (inMessage == 'PRSL') aSlider->Refresh();
  240.  
  241.             aSlider = (AGASliderPP*) mCurrentDialog->FindPaneByID('VSRC');
  242.             aSlider->mAGAObject->SetAttributes(AGAObject::kVertical, live, proportional);
  243.             if (inMessage == 'PRSL') aSlider->Refresh();
  244.  
  245.             aSlider = (AGASliderPP*) mCurrentDialog->FindPaneByID('HSPL');
  246.             aSlider->mAGAObject->SetAttributes(AGAObject::kHorizontal, live, proportional);
  247.             if (inMessage == 'PRSL') aSlider->Refresh();
  248.  
  249.             aSlider = (AGASliderPP*) mCurrentDialog->FindPaneByID('HSPR');
  250.             aSlider->mAGAObject->SetAttributes(AGAObject::kHorizontal, live, proportional);
  251.             if (inMessage == 'PRSL') aSlider->Refresh();
  252.  
  253.             aSlider = (AGASliderPP*) mCurrentDialog->FindPaneByID('HSRC');
  254.             aSlider->mAGAObject->SetAttributes(AGAObject::kHorizontal, live, proportional);
  255.             if (inMessage == 'PRSL') aSlider->Refresh();
  256.             }
  257.             break;
  258.  
  259.         case 'GO_1':
  260.             {
  261.             // Save the pointer to the indeterminate progress indicator,
  262.             // so we'll increment it at idle. Swap the enable states
  263.             // of its Go and Stop buttons.
  264.  
  265.             this->ToggleButtons('GO_1', 'STP1');
  266.             
  267.             mProgressIndicator1 = (AGAProgressIndicatorPP*) mCurrentDialog->FindPaneByID('PRG1');
  268.             
  269.             mProgressIndicator1->StartAutoAnimate();
  270.             }
  271.             break;
  272.         
  273.         case 'GO_2':
  274.             {
  275.             // Save the pointer to the determinate progress indicator,
  276.             // so we'll increment it at idle. Swap the enable states
  277.             // of its Go and Stop buttons.
  278.  
  279.             this->ToggleButtons('GO_2', 'STP2');
  280.             
  281.             mProgressIndicator2 = (AGAProgressIndicatorPP*) mCurrentDialog->FindPaneByID('PRG2');
  282.             }
  283.             break;
  284.         
  285.         case 'STP1':
  286.             {
  287.             // Null the pointer to the indeterminate progress indicator,
  288.             // so we'll ignore it at idle. Swap the enable states
  289.             // of its Go and Stop buttons.
  290.  
  291.             this->ToggleButtons('STP1', 'GO_1');
  292.             
  293.             mProgressIndicator1 = (AGAProgressIndicatorPP*) mCurrentDialog->FindPaneByID('PRG1');
  294.             
  295.             mProgressIndicator1->StopAutoAnimate();
  296.             
  297.             mProgressIndicator1 = NULL;
  298.             }
  299.             break;
  300.         
  301.         case 'STP2':
  302.             {
  303.             // Null the pointer to the determinate progress indicator,
  304.             // so we'll ignore it at idle. Swap the enable states
  305.             // of its Go and Stop buttons.
  306.  
  307.             this->ToggleButtons('STP2', 'GO_2');
  308.             
  309.             mProgressIndicator2 = NULL;
  310.             }
  311.             break;
  312.             
  313.         case 'SETV':
  314.             {
  315.             // The "Set Values" button in the progress dialog was hit.
  316.             // Poke the determinate progress indicator with the current
  317.             // values that have been entered in the dialog.
  318.  
  319.             LEditField*        aNumberText;
  320.             LStdCheckBox*    originCheckBox = (LStdCheckBox*) mCurrentDialog->FindPaneByID('CORG');
  321.             SInt32            newMin;
  322.             SInt32            newMax;
  323.             SInt32            newValue;
  324.             SInt32            newOrigin;
  325.  
  326.             AGAProgressIndicatorPP*    indicator = (AGAProgressIndicatorPP*) mCurrentDialog->FindPaneByID('PRG2');
  327.             
  328.             aNumberText = (LEditField*) mCurrentDialog->FindPaneByID('NMIN');
  329.             newMin = aNumberText->GetValue();
  330.             
  331.             aNumberText = (LEditField*) mCurrentDialog->FindPaneByID('NMAX');
  332.             newMax = aNumberText->GetValue();
  333.             
  334.             indicator->mAGAObject->SetRange(newMin, newMax, AGAObject::kDontRedraw);
  335.             
  336.             aNumberText = (LEditField*) mCurrentDialog->FindPaneByID('NVAL');
  337.             newValue = aNumberText->GetValue();
  338.             indicator->mAGAObject->SetValue(newValue, AGAObject::kDontRedraw);
  339.             
  340.             if (originCheckBox->GetValue() == 0)
  341.                 newOrigin = newMin;
  342.             else
  343.                 {
  344.                 aNumberText = (LEditField*) mCurrentDialog->FindPaneByID('NORG');
  345.                 newOrigin = MaxSInt32(newMin, aNumberText->GetValue());
  346.                 }
  347.             
  348.             indicator->mAGAObject->SetOriginValue(newOrigin, AGAObject::kDontRedraw);
  349.             
  350.             indicator->Refresh();
  351.             }
  352.             break;
  353.             
  354.         case 'CORG':
  355.             {
  356.             // The progress dialog's "Moving Origin" checkbox was hit.
  357.             // Enable or disable the edit text and little arrows, and
  358.             // set our flag that we'll check at idle.
  359.  
  360.             LStdCheckBox*    aCheckBox = (LStdCheckBox*) mCurrentDialog->FindPaneByID('CORG');
  361.             Boolean            enabled = (aCheckBox->GetValue() != 0);
  362.             
  363.             this->EnableDisablePane('NORG', enabled);
  364.             this->EnableDisablePane('AORG', enabled);
  365.             this->EnableDisablePane('TORG', enabled);
  366.             
  367.             mMovingProgressOrigin = enabled;
  368.             }
  369.             break;
  370.  
  371.         }
  372.     }
  373.  
  374. void MyApplication::ToggleButtons(OSType buttonToDisable, OSType buttonToEnable)
  375.     {
  376.     mCurrentDialog->FindPaneByID(buttonToDisable)->Disable();
  377.     mCurrentDialog->FindPaneByID(buttonToEnable)->Enable();
  378.     }
  379.  
  380. void MyApplication::EnableDisablePane(OSType paneID, Boolean enable)
  381.     {
  382.     if (enable)
  383.         mCurrentDialog->FindPaneByID(paneID)->Enable();
  384.     else
  385.         mCurrentDialog->FindPaneByID(paneID)->Disable();
  386.     }
  387.  
  388. void MyApplication::SpendTime(const EventRecord& /*inMacEvent*/)
  389.     {
  390.     // If we have a pointer to the determinate progress indicator,
  391.     // it's running, so increment its value.
  392.     if (mProgressIndicator2 != NULL)
  393.         {
  394.         mProgressIndicator2->FocusDraw();
  395.         mProgressIndicator2->mAGAObject->Increment(1, AGAObject::kRedraw);
  396.         
  397.         // Increment the origin every other time, if it's moving.
  398.         if (mMovingProgressOrigin && ! mSkipNext)
  399.             mProgressIndicator2->mAGAObject->SetOriginValue(1 + mProgressIndicator2->mAGAObject->GetOriginValue(), AGAObject::kRedraw);
  400.         
  401.         mSkipNext = ! mSkipNext;    // make moving origin go slower than value
  402.         }
  403.     }
  404.  
  405. void MyApplication::PoseExampleDialog(UInt32 dialogIndex)
  406.     {
  407.     // Run one of our test dialogs.
  408.  
  409.     StDialogHandler    aDlgHandler(kMyViewBase + dialogIndex, this);
  410.     LWindow*        aDialog = aDlgHandler.GetDialog();
  411.     MessageT        hitMessage;
  412.  
  413.     mCurrentDialog = aDialog;
  414.     mCurrentDialogIndex = dialogIndex;
  415.     
  416.     this->SetupExampleDialog(dialogIndex, aDialog);
  417.     
  418.     aDialog->Show();
  419.     
  420.     do
  421.         {
  422.  
  423.         hitMessage = aDlgHandler.DoDialog();
  424.  
  425.         } while ((hitMessage != msg_OK) && (hitMessage != msg_Cancel));
  426.  
  427.     this->CleanupExampleDialog(dialogIndex, aDialog);
  428.     }
  429.  
  430. void MyApplication::SetupExampleDialog(UInt32 dialogIndex, LWindow* itsWindow)
  431.     {
  432.     // Set up one of our test dialogs, just prior to showing it.
  433.  
  434.     LPane*        aPane;
  435.     LControl*    aBroadcaster = (LControl*) itsWindow->FindPaneByID('ENAB');
  436.     if (aBroadcaster != NULL)    // not all of our commands have this checkbox!
  437.         aBroadcaster->AddListener(this);
  438.  
  439.     switch (dialogIndex)
  440.         {
  441.         case kPushButtonDlgIndex:
  442.  
  443.             aPane = itsWindow->FindPaneByID('DFLT');
  444.             ((AGAPushButtonPP*) aPane)->mAGAObject->SetDefault(AGAObject::kIsDefault, AGAObject::kFrameOutside);
  445.  
  446.             break;
  447.  
  448.         case kCheckBoxDlgIndex:
  449.  
  450.             aPane = itsWindow->FindPaneByID('CBX3');
  451.             ((LStdCheckBox*) aPane)->SetValue(AGACheckBox::kCheckBoxMixed);
  452.  
  453.             break;
  454.  
  455.         case kRadioButtonDlgIndex:
  456.  
  457.             aPane = itsWindow->FindPaneByID('BTN3');
  458.             ((LStdRadioButton*) aPane)->SetValue(AGARadioButton::kRadioButtonMixed);
  459.  
  460.             break;
  461.  
  462.         case kScrollBarDlgIndex:
  463.  
  464.             ((LControl*) itsWindow->FindPaneByID('LIVE'))->AddListener(this);
  465.             ((LControl*) itsWindow->FindPaneByID('PROP'))->AddListener(this);
  466.  
  467.             aPane = itsWindow->FindPaneByID('SBAR');
  468.             ((LControl*) aPane)->AddListener(this);
  469.             ((AGAScrollBarPP*) aPane)->mAGAObject->SetLiveTracking(AGAObject::kLiveTracking);
  470.             ((AGAScrollBarPP*) aPane)->mAGAObject->SetPageSize(25, AGAObject::kDontRedraw);
  471.             ((AGAScrollBarPP*) aPane)->mAGAObject->SetStepSizes(1, 25);
  472.  
  473.             aPane = itsWindow->FindPaneByID('BIGP');
  474.             ((LControl*) aPane)->AddListener(this);
  475.  
  476.             aPane = itsWindow->FindPaneByID('LILP');
  477.             ((LControl*) aPane)->AddListener(this);
  478.  
  479.             break;
  480.  
  481.         case kSliderDlgIndex:
  482.             {
  483.             AGASliderPP*    aSlider;
  484.  
  485.             ThrowIfNil_(aSlider = (AGASliderPP*) itsWindow->FindPaneByID('VSPL'));
  486.             aSlider->mAGAObject->SetPageSize(1, AGAObject::kDontRedraw);
  487.  
  488.             ThrowIfNil_(aSlider = (AGASliderPP*) itsWindow->FindPaneByID('VSRC'));
  489.             aSlider->mAGAObject->SetPageSize(20, AGAObject::kDontRedraw);
  490.  
  491.             ThrowIfNil_(aSlider = (AGASliderPP*) itsWindow->FindPaneByID('VSPR'));
  492.             aSlider->mAGAObject->SetJustification(teFlushRight);
  493.             aSlider->mAGAObject->SetPageSize(1, AGAObject::kDontRedraw);
  494.  
  495.             ThrowIfNil_(aSlider = (AGASliderPP*) itsWindow->FindPaneByID('HSPL'));
  496.             aSlider->mAGAObject->SetPageSize(1, AGAObject::kDontRedraw);
  497.  
  498.             ThrowIfNil_(aSlider = (AGASliderPP*) itsWindow->FindPaneByID('HSRC'));
  499.             aSlider->mAGAObject->SetPageSize(20, AGAObject::kDontRedraw);
  500.  
  501.             ThrowIfNil_(aSlider = (AGASliderPP*) itsWindow->FindPaneByID('HSPR'));
  502.             aSlider->mAGAObject->SetJustification(teFlushRight);
  503.             aSlider->mAGAObject->SetPageSize(1, AGAObject::kDontRedraw);
  504.             aSlider->SetMaxValue(32);
  505.  
  506.             aBroadcaster = (LControl*) itsWindow->FindPaneByID('LVSL');
  507.             aBroadcaster->AddListener(this);
  508.  
  509.             aBroadcaster = (LControl*) itsWindow->FindPaneByID('PRSL');
  510.             aBroadcaster->AddListener(this);
  511.             }
  512.             break;
  513.  
  514.         case kProgressDlgIndex:
  515.             {
  516.             ((LControl*) itsWindow->FindPaneByID('GO_1'))->AddListener(this);
  517.             ((LControl*) itsWindow->FindPaneByID('GO_2'))->AddListener(this);
  518.             ((LControl*) itsWindow->FindPaneByID('STP1'))->AddListener(this);
  519.             ((LControl*) itsWindow->FindPaneByID('STP2'))->AddListener(this);
  520.             ((LControl*) itsWindow->FindPaneByID('SETV'))->AddListener(this);
  521.             ((LControl*) itsWindow->FindPaneByID('CORG'))->AddListener(this);
  522.             }
  523.             break;
  524.  
  525.         case kFolderTabsDlgIndex:
  526.             {
  527.             ((LControl*) itsWindow->FindPaneByID('LRGT'))->AddListener(this);
  528.             ((LControl*) itsWindow->FindPaneByID('SMLT'))->AddListener(this);
  529.             
  530.             AGATabPanelPP*    theTabPanel;
  531.             
  532.             ThrowIfNil_(theTabPanel = (AGATabPanelPP*) itsWindow->FindPaneByID('TAB1'));
  533.                         
  534.             theTabPanel->InstallPanel(0, 3000, NULL);
  535.             theTabPanel->InstallPanel(1, 3001, NULL);
  536.             theTabPanel->InstallPanel(2, 3002, NULL);
  537.             
  538.             LView*        aPanelView;
  539.             LListBox*    aListBox;
  540.             ListHandle    aListHandle;
  541.             Str255        someData;
  542.             Cell        aCell;
  543.             
  544.             ThrowIfNil_(aPanelView = theTabPanel->GetPanelView(2));
  545.  
  546.             ThrowIfNil_(aListBox = (LListBox*) aPanelView->FindPaneByID('TVW1'));
  547.             ThrowIfNil_(aListHandle = aListBox->GetMacListH());
  548.             ::LAddColumn(1, 0, aListHandle);
  549.             
  550.             for (UInt32 i = 0; i < kNumListDataStrings; i++)
  551.                 {
  552.                 ::GetIndString(someData, kExtraStringBase+kListDataStrings, i+1);
  553.                 ::LAddRow(1, i, aListHandle);
  554.                 ::SetPt(&aCell, 0, i);
  555.                 ::LSetCell(&someData[1], someData[0], aCell, aListHandle);
  556.                 }
  557.  
  558.             ThrowIfNil_(aListBox = (LListBox*) aPanelView->FindPaneByID('TVW2'));
  559.             ThrowIfNil_(aListHandle = aListBox->GetMacListH());
  560.             ::LAddColumn(1, 0, aListHandle);
  561.             
  562.             for (UInt32 i = 0; i < kNumListDataStrings; i++)
  563.                 {
  564.                 ::GetIndString(someData, kExtraStringBase+kListDataStrings, i+1);
  565.                 ::LAddRow(1, i, aListHandle);
  566.                 ::SetPt(&aCell, 0, i);
  567.                 ::LSetCell(&someData[1], someData[0], aCell, aListHandle);
  568.                 }
  569.             }
  570.             break;
  571.  
  572.         case kFocusBorderDlgIndex:
  573.             {
  574.             LListBox*    aListBox;
  575.             ListHandle    aListHandle;
  576.             Str255        someData;
  577.             Cell        aCell;
  578.             
  579.             ThrowIfNil_(aListBox = (LListBox*) itsWindow->FindPaneByID('TVW1'));
  580.             ThrowIfNil_(aListHandle = aListBox->GetMacListH());
  581.             ::LAddColumn(1, 0, aListHandle);
  582.             
  583.             for (UInt32 i = 0; i < kNumListDataStrings; i++)
  584.                 {
  585.                 ::GetIndString(someData, kExtraStringBase+kListDataStrings, i+1);
  586.                 ::LAddRow(1, i, aListHandle);
  587.                 ::SetPt(&aCell, 0, i);
  588.                 ::LSetCell(&someData[1], someData[0], aCell, aListHandle);
  589.                 }
  590.  
  591.             ThrowIfNil_(aListBox = (LListBox*) itsWindow->FindPaneByID('TVW2'));
  592.             ThrowIfNil_(aListHandle = aListBox->GetMacListH());
  593.             ::LAddColumn(1, 0, aListHandle);
  594.             
  595.             for (UInt32 i = 0; i < kNumListDataStrings; i++)
  596.                 {
  597.                 ::GetIndString(someData, kExtraStringBase+kListDataStrings, i+1);
  598.                 ::LAddRow(1, i, aListHandle);
  599.                 ::SetPt(&aCell, 0, i);
  600.                 ::LSetCell(&someData[1], someData[0], aCell, aListHandle);
  601.                 }
  602.  
  603.             ThrowIfNil_(aListBox = (LListBox*) itsWindow->FindPaneByID('TVW3'));
  604.             ThrowIfNil_(aListHandle = aListBox->GetMacListH());
  605.             ::LAddColumn(1, 0, aListHandle);
  606.             
  607.             for (UInt32 i = 0; i < kNumListDataStrings; i++)
  608.                 {
  609.                 ::GetIndString(someData, kExtraStringBase+kListDataStrings, i+1);
  610.                 ::LAddRow(1, i, aListHandle);
  611.                 ::SetPt(&aCell, 0, i);
  612.                 ::LSetCell(&someData[1], someData[0], aCell, aListHandle);
  613.                 }
  614.             }
  615.             break;
  616.  
  617.         }
  618.     }
  619.  
  620. void MyApplication::CleanupExampleDialog(UInt32 dialogIndex, LWindow* /*itsWindow*/)
  621.     {
  622.     // Clean up one of our dialogs that is being closed.
  623.  
  624.     switch (dialogIndex)
  625.         {
  626.         case kProgressDlgIndex:
  627.             {
  628.             // Null the pointers so we don't go haywire at next idle !
  629.  
  630.             mProgressIndicator1 = NULL;
  631.             mProgressIndicator2 = NULL;
  632.             mMovingProgressOrigin = false;
  633.             mSkipNext = false;
  634.             }
  635.             break;
  636.         }
  637.     }
  638.  
  639. static void EnablePane(LPane* aPane, Boolean enable)
  640.     {
  641.     ThrowIfNil_(aPane);
  642.  
  643.     if (enable)
  644.         aPane->Enable();
  645.     else
  646.         aPane->Disable();
  647.     }
  648.  
  649. void MyApplication::EnableDisableDialog(UInt32 dialogIndex, LWindow* itsWindow, Boolean enable)
  650.     {
  651.     // There is an 'ENAB' check box in many of our dialogs,
  652.     // that enables/disables bunches o' items in the dialogs.
  653.  
  654.     switch (dialogIndex)
  655.         {
  656.         case kPushButtonDlgIndex:
  657.  
  658.             EnablePane(itsWindow->FindPaneByID('NORM'), enable);
  659.             EnablePane(itsWindow->FindPaneByID('DFLT'), enable);
  660.             EnablePane(itsWindow->FindPaneByID('ICN1'), enable);
  661.             EnablePane(itsWindow->FindPaneByID('ICN2'), enable);
  662.             EnablePane(itsWindow->FindPaneByID('ICN3'), enable);
  663.  
  664.             break;
  665.  
  666.         case kCheckBoxDlgIndex:
  667.  
  668.             EnablePane(itsWindow->FindPaneByID('ICN1'), enable);
  669.             EnablePane(itsWindow->FindPaneByID('ICN2'), enable);
  670.             EnablePane(itsWindow->FindPaneByID('ICN3'), enable);
  671.             EnablePane(itsWindow->FindPaneByID('CBX1'), enable);
  672.             EnablePane(itsWindow->FindPaneByID('CBX2'), enable);
  673.             EnablePane(itsWindow->FindPaneByID('CBX3'), enable);
  674.  
  675.             break;
  676.  
  677.         case kRadioButtonDlgIndex:
  678.  
  679.             EnablePane(itsWindow->FindPaneByID('BTN1'), enable);
  680.             EnablePane(itsWindow->FindPaneByID('BTN2'), enable);
  681.             EnablePane(itsWindow->FindPaneByID('BTN3'), enable);
  682.             EnablePane(itsWindow->FindPaneByID('ICN1'), enable);
  683.             EnablePane(itsWindow->FindPaneByID('ICN2'), enable);
  684.             EnablePane(itsWindow->FindPaneByID('ICN3'), enable);
  685.             EnablePane(itsWindow->FindPaneByID('ICN4'), enable);
  686.             EnablePane(itsWindow->FindPaneByID('ICN5'), enable);
  687.             EnablePane(itsWindow->FindPaneByID('ICN6'), enable);
  688.             EnablePane(itsWindow->FindPaneByID('ICN7'), enable);
  689.  
  690.             break;
  691.  
  692.         case kSliderDlgIndex:
  693.  
  694.             EnablePane(itsWindow->FindPaneByID('VSPL'), enable);
  695.             EnablePane(itsWindow->FindPaneByID('VSRC'), enable);
  696.             EnablePane(itsWindow->FindPaneByID('VSPR'), enable);
  697.             EnablePane(itsWindow->FindPaneByID('HSPL'), enable);
  698.             EnablePane(itsWindow->FindPaneByID('HSRC'), enable);
  699.             EnablePane(itsWindow->FindPaneByID('HSPR'), enable);
  700.  
  701.             break;
  702.  
  703.         case kScrollBarDlgIndex:
  704.  
  705.             EnablePane(itsWindow->FindPaneByID('SBAR'), enable);
  706.             EnablePane(itsWindow->FindPaneByID(PaneIDT_HorizontalScrollBar), enable);
  707.             EnablePane(itsWindow->FindPaneByID(PaneIDT_VerticalScrollBar), enable);
  708.  
  709.             break;
  710.  
  711.         case kPopupMenuDlgIndex:
  712.  
  713.             EnablePane(itsWindow->FindPaneByID('POP1'), enable);
  714.             EnablePane(itsWindow->FindPaneByID('POP2'), enable);
  715.             EnablePane(itsWindow->FindPaneByID('POP3'), enable);
  716.  
  717.             break;
  718.  
  719.         case kEditTextDlgIndex:
  720.  
  721.             EnablePane(itsWindow->FindPaneByID('EDT1'), enable);
  722.  
  723.             break;
  724.  
  725.         case kGroupBoxDlgIndex:
  726.         
  727.             EnablePane(itsWindow->FindPaneByID('GRP1'), enable);
  728.                 EnablePane(itsWindow->FindPaneByID('GR1A'), enable);
  729.                     EnablePane(itsWindow->FindPaneByID('R1A1'), enable);
  730.                     EnablePane(itsWindow->FindPaneByID('R1A2'), enable);
  731.                 EnablePane(itsWindow->FindPaneByID('GR1B'), enable);
  732.                     EnablePane(itsWindow->FindPaneByID('R1B1'), enable);
  733.                     EnablePane(itsWindow->FindPaneByID('R1B2'), enable);
  734.  
  735.             EnablePane(itsWindow->FindPaneByID('GRP2'), enable);
  736.                 EnablePane(itsWindow->FindPaneByID('GR2A'), enable);
  737.                     EnablePane(itsWindow->FindPaneByID('R2A1'), enable);
  738.                     EnablePane(itsWindow->FindPaneByID('R2A2'), enable);
  739.                 EnablePane(itsWindow->FindPaneByID('GR2B'), enable);
  740.                     EnablePane(itsWindow->FindPaneByID('R2B1'), enable);
  741.                     EnablePane(itsWindow->FindPaneByID('R2B2'), enable);
  742.  
  743.             EnablePane(itsWindow->FindPaneByID('GRP3'), enable);
  744.                 EnablePane(itsWindow->FindPaneByID('GR3A'), enable);
  745.                     EnablePane(itsWindow->FindPaneByID('R3A1'), enable);
  746.                     EnablePane(itsWindow->FindPaneByID('R3A2'), enable);
  747.                 EnablePane(itsWindow->FindPaneByID('GR3B'), enable);
  748.                     EnablePane(itsWindow->FindPaneByID('R3B1'), enable);
  749.                     EnablePane(itsWindow->FindPaneByID('R3B2'), enable);
  750.  
  751.             EnablePane(itsWindow->FindPaneByID('CBX1'), enable);
  752.             EnablePane(itsWindow->FindPaneByID('CBX2'), enable);
  753.             EnablePane(itsWindow->FindPaneByID('CBX3'), enable);
  754.  
  755.             break;
  756.  
  757.         case kFolderTabsDlgIndex:
  758.  
  759.             EnablePane(itsWindow->FindPaneByID('TAB1'), enable);
  760.             EnablePane(itsWindow->FindPaneByID('TAB2'), enable);
  761.             
  762.             break;
  763.  
  764.         case kFocusBorderDlgIndex:
  765.  
  766.             EnablePane(itsWindow->FindPaneByID('TVW1'), enable);
  767.             EnablePane(itsWindow->FindPaneByID('TVW2'), enable);
  768.             EnablePane(itsWindow->FindPaneByID('TVW3'), enable);
  769.             
  770.             // std enable/disable does not let attachments redraw!!! ick!
  771.             //itsWindow->Refresh();
  772.  
  773.             break;
  774.  
  775.         }
  776.     }
  777.  
  778.